<template>
  <div>
    <el-container>
      <el-header><h1>森林病虫害防治系统</h1></el-header>
      <el-container>
        <el-aside width="300px">
          <el-tree
            :data="data"
            :props="defaultProps"
            accordion
            @node-click="handleNodeClick"
          >
          </el-tree>
        </el-aside>
        <el-container>
          <el-main>
            <router-view />
          </el-main>
        </el-container>
      </el-container>
    </el-container>
  </div>
</template>

<script>
export default {
  data() {
    return {
      data: [
        {
          label: "森林病虫害防治系统",
          children: [
            {
              label: "资料管理",
              children: [
                {
                  label: "虫害一览",
                },
                {
                  label: "病害一览",
                },
                {
                  label: "鼠害一览",
                },
              ],
            },
            {
              label: "灾情防治",
              children: [
                {
                  label: "区域一览",
                },
                {
                  label: "小班管理",
                },
                {
                  label: "事件记录",
                },
              ],
            },
            {
              label: "专家会商",
              children: [
                {
                  label: "专家一览",
                },
                {
                  label: "会商灾情",
                },
              ],
            },
            {
              label: "药剂器械出库管理",
              children: [
                {
                  label: "药剂管理",
                },
                {
                  label: "出库管理",
                },
              ],
            },
            {
              label: "系统信息",
              children: [
                {
                  label: "用户管理",
                },
                {
                  label: "日志一览",
                },
              ],
            },
          ],
        },
      ],
      defaultProps: {
        children: "children",
        label: "label",
      },
    };
  },
  methods: {
    handleNodeClick(data) {
      console.log(data);
      if (data.label == "虫害一览") {
        this.$router.push("/home/pest");
      }
      if (data.label == "病害一览") {
        this.$router.push("/home/disease");
      }
      if (data.label == "鼠害一览") {
        this.$router.push("/home/mouse");
      }
      if (data.label == "区域一览") {
        this.$router.push("/home/area");
      }
      if (data.label == "小班管理") {
        this.$router.push("/home/classes");
      }
      if (data.label == "事件记录") {
        this.$router.push("/home/thing");
      }
    },
  },
};
</script>

<style>
h1 {
  text-align: center;
}
</style>